package com.huage_09.lesson_03;

import java.util.function.Consumer;

public class ConsumerDemo {
    public static void main(String[] args) {
        String[] strs = {"张三,23","李四,24","王五,25"};

//        printInfo(strs,(s) -> {
//            String name = s.split(",")[0];
//            System.out.print("姓名:"+name);
//        },(s)->{
//            String name = s.split(",")[1];
//            System.out.println(",年龄:"+name);
//        });
        printInfo(strs,s -> System.out.print("姓名:"+s.split(",")[0]),
                s -> System.out.println(",年龄:"+s.split(",")[1]));
    }
    public static void printInfo(String[] strs, Consumer<String> con1,Consumer<String> con2){
        for (String str :strs){
            con1.andThen(con2).accept(str);
        }
    }
}
